package com.ailanyin.admin.config;

import com.ailanyin.admin.service.impl.UserDetailsServiceImpl;
import com.ailanyin.security.config.BaseSecurityConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.core.userdetails.UserDetailsService;

/**
 * @author ailanyin
 * @version 1.0
 * @since 2021/10/19 0019 上午 11:54
 */
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled=true)
public class AdminSecurityConfig extends BaseSecurityConfig {

    @Autowired
    private UserDetailsServiceImpl userDetailsService;


    @Bean
    @Override
    public UserDetailsService userDetailsService() {
        //获取登录用户信息
        return username -> userDetailsService.loadUserByUsername(username);
    }

}
